package com.zyh.scs.admin.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zyh.scs.admin.api.dto.TransactionBillDTO;
import com.zyh.scs.admin.api.entity.UserTransaction;
import com.zyh.scs.admin.api.vo.BillExcelVO;
import com.zyh.scs.admin.api.vo.UserTransactionGroupByAllVO;
import com.zyh.scs.admin.api.vo.UserTransactionGroupByTimeVO;
import com.zyh.scs.admin.api.vo.account.DeductionBillExcelVO;
import com.zyh.scs.admin.api.vo.account.PaymentBillExcelVO;
import com.zyh.scs.admin.api.vo.account.TransactionGroupUserIdVO;
import com.zyh.scs.admin.api.vo.account.TransactionGroupVO;
import com.zyh.scs.common.data.datascope.ScsBaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDateTime;
import java.util.List;

/**
 * @author hwh
 * @ClassName: 统计报表交易流水mapper$
 * @Description: $
 * @Date $
 * @Version 1.0
 */
@Mapper
public interface UserTransactionMapper extends ScsBaseMapper<UserTransaction> {


    /**
     * 根据时间查询交易流水期初值
     *
     * @param time
     * @return
     */
    List<UserTransactionGroupByTimeVO> getUserIdGroupByBeginTime(@Param("time") LocalDateTime time);

    /**
     * 根据时间查询交易流水期初值统计总和
     *
     * @param time
     * @return
     */
    UserTransactionGroupByAllVO getUserIdGroupByBeginTimeAll(@Param("time") LocalDateTime time);


    /**
     * 根据时间查询交易流水期末值
     *
     * @param time
     * @return
     */
    List<UserTransactionGroupByTimeVO> getUserIdGroupByEndTime(@Param("time") LocalDateTime time);

    /**
     * 根据时间查询交易流水期末值
     *
     * @param time
     * @return
     */
    UserTransactionGroupByAllVO getUserIdGroupByEndTimeAll(@Param("time") LocalDateTime time);


    /**
     * 满客宝京东好店 支付流水 统计
     *
     * @param type 2为满客宝  4为京东  7为好店
     * @return
     */
    List<PaymentBillExcelVO> getPayment(@Param("channelName") String channelName, @Param("type") String type,
                                        @Param("beginTime") LocalDateTime beginTime, @Param("endTime") LocalDateTime endTime);


    /**
     * 满客宝京东好店 退款流水 统计
     *
     * @param type 3为满客宝  5为京东  8为好店
     * @return
     */
    List<DeductionBillExcelVO> getDeduction(@Param("channelName") String channelName, @Param("type") String type,
                                            @Param("beginTime") LocalDateTime beginTime, @Param("endTime") LocalDateTime endTime);


    /**
     * 通过订单id去查询退款流水对应的支付流水
     *
     * @param type
     * @param accountType
     * @return
     */
    List<DeductionBillExcelVO> getPayByOrderNumber(@Param("type") String type, @Param("accountType") String accountType);


    /**
     * 根据type获取transaction_number总和   时间泛微内
     * map 充值为 1  支付为2 退款为3
     *
     * @return
     */
    List<TransactionGroupVO> getTransactionGroupByType(@Param("beginTime") LocalDateTime beginTime, @Param("endTime") LocalDateTime endTime);


    List<TransactionGroupVO> getBusinessTo(@Param("beginTime") LocalDateTime beginTime, @Param("endTime") LocalDateTime endTime, @Param("accountType") String accountType);


    List<TransactionGroupUserIdVO> getBusinessUserId(@Param("beginTime") LocalDateTime beginTime, @Param("endTime") LocalDateTime endTime, @Param("accountType") String accountType);


    /**
     * 交易流水账单
     */
    IPage<BillExcelVO> getTransactionBill(@Param("page") Page page,@Param("query") TransactionBillDTO query);

    /**
     * 交易流水账单 总数
     */
    int getTransactionBillCount(@Param("beginTime") LocalDateTime beginTime, @Param("endTime") LocalDateTime endTime);

}
